package com.dgut.lotterySystem.service.mq;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

import static com.dgut.lotterySystem.common.config.DirectRabbitConfig.*;

@Component
@RabbitListener(queues = DLX_QUEUE_NAME)
public class DlxMQReceiver {
    public static final Logger logger= LoggerFactory.getLogger(DlxMQReceiver.class);
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RabbitHandler
    public void process(Map<String,String> message){
        logger.info("开始处理异常的信息");
        rabbitTemplate.convertAndSend(EXCHANGE_NAME,ROUTING,message);

        //正常流程

        //接收到异常消息，消息堆积-》消息处理-》消息重发
        //1.接收到异常消息，可以将异常消息持久化存储到数据库中
        //2.解决异常
        //3.完成脚本消息，判断是否存在异常消息，处理异常消息
        //处理好异常，发送到消息处理
    }
}
